package com.pmcc.core.entity.security;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pmcc.core.entity.BaseEntity;
import com.pmcc.core.enums.ModuleType;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by syk on 17/7/6.
 */
@Getter
@Setter
@Entity
@Table(name = "SYS_MENU")
public class Menu extends BaseEntity {

    @Column(name = "NAME", length = 100)
    private String name;

    @Column(name = "CODE", length = 100)
    private String code;

    @Column(name = "ICON", length = 100)
    private String icon;//图标

    @Column(name = "PATH", length = 100)
    private String path;//路径

    @Column(name = "PARENT_ID", length = 32)
    private String parentId;//上级菜单-1为一级菜单

    @Column(name = "SORT_NO", length = 11)
    private Integer sortNo;//排序编号

    @Column(name = "TYPE", length = 50)
    @Enumerated(EnumType.STRING)
    private ModuleType moduleType;//类型 0菜单 1工具栏按钮 2请求 3行操作按钮 4页面按钮

    @Column(name = "IS_LEAF")
    private Boolean isLeaf;

    @JsonIgnore
    @ManyToMany(mappedBy = "menuSet", fetch = FetchType.EAGER)
    private List<Role> roleList = new ArrayList<>();


    @Column(name = "CLICK_EVENT")
    private String clickEvent;

    public Boolean getLeaf() {
        return isLeaf;
    }

    public void setLeaf(Boolean leaf) {
        isLeaf = leaf;
    }
}
